package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.domain.BrandAudiConfig;
import com.ruoyi.system.domain.SysMenu;
import com.ruoyi.system.service.IBrandAudiConfigService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 品牌车系Controller
 * 
 * @author WUYIBO
 * @date 2024-07-16
 */
@RestController
@RequestMapping("/brandAudiConfig")
public class BrandAudiConfigController extends BaseController
{
    @Autowired
    private IBrandAudiConfigService brandAudiConfigService;

    /**
     * 查询品牌车系列表
     */
//    @RequiresPermissions("system:brandAudiConfig:list")
    @GetMapping("/list")
    public TableDataInfo list(BrandAudiConfig brandAudiConfig)
    {
        startPage();
        List<BrandAudiConfig> list = brandAudiConfigService.selectBrandAudiConfigList(brandAudiConfig);
        return getDataTable(list);
    }
    /**
     * 获取树形列表
     */
    @GetMapping("/tree")
    public AjaxResult tree(BrandAudiConfig menu)
    {
        Long userId = SecurityUtils.getUserId();
        List<BrandAudiConfig> menus = brandAudiConfigService.selectTreeList(menu, userId);
        return AjaxResult.success(menus);
    }

    /**
     * 获取级联树形列表
     */
    @GetMapping("/cascaderTree")
    public AjaxResult cascaderTree(BrandAudiConfig menu)
    {
        Long userId = SecurityUtils.getUserId();
        List<BrandAudiConfig> menus = brandAudiConfigService.selectTreeList(menu, userId);
        return AjaxResult.success(menus);
    }
    /**
     * 导出品牌车系列表
     */
    @RequiresPermissions("system:brandAudiConfig:export")
    @Log(title = "品牌车系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BrandAudiConfig brandAudiConfig)
    {
        List<BrandAudiConfig> list = brandAudiConfigService.selectBrandAudiConfigList(brandAudiConfig);
        ExcelUtil<BrandAudiConfig> util = new ExcelUtil<BrandAudiConfig>(BrandAudiConfig.class);
        util.exportExcel(response, list, "品牌车系数据");
    }

    /**
     * 获取品牌车系详细信息
     */
//    @RequiresPermissions("system:brandAudiConfig:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(brandAudiConfigService.selectBrandAudiConfigById(id));
    }

    /**
     * 新增品牌车系
     */
//    @RequiresPermissions("system:brandAudiConfig:add")
    @Log(title = "品牌车系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BrandAudiConfig brandAudiConfig)
    {
        return toAjax(brandAudiConfigService.insertBrandAudiConfig(brandAudiConfig));
    }

    /**
     * 修改品牌车系
     */
//    @RequiresPermissions("system:brandAudiConfig:edit")
    @Log(title = "品牌车系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BrandAudiConfig brandAudiConfig)
    {
        return toAjax(brandAudiConfigService.updateBrandAudiConfig(brandAudiConfig));
    }

    /**
     * 删除品牌车系
     */
//    @RequiresPermissions("system:brandAudiConfig:remove")
    @Log(title = "品牌车系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(brandAudiConfigService.deleteBrandAudiConfigByIds(ids));
    }
}
